package com.mdz.nc.Controller;


import com.mdz.nc.Entity.KsWj;
import com.mdz.nc.Mapper.KsWjMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 孟德志
 * @since 2020-05-07
 */
@Controller
@RequestMapping("/nc/ksWj")
public class KsWjController {
    @Autowired
    private KsWjMapper ksWjMapper;
    @Autowired
    private HttpServletRequest request;

    @ResponseBody
    @RequestMapping(value = "/insertwjdc",method = RequestMethod.POST)
    public Integer insertwjdc(KsWj ksWjs){
        int j=0;
        String[] xzanswer = ksWjs.getXzAnswer().split(",");
        for(int i=0; i<xzanswer.length; i++){
            ksWjs.setWjdcId(i+Integer.parseInt(request.getParameter("wjdcId")));
            ksWjs.setXzAnswer(xzanswer[i]);
            j=ksWjMapper.insert(ksWjs);
        }
        return j;
    }

    @ResponseBody
    @RequestMapping("/optional_a")
    public List<KsWj> optional_a(ModelMap map){
        List<KsWj> ksWjsa=ksWjMapper.selectbycounta();
        return ksWjsa;
    }
    @ResponseBody
    @RequestMapping("/optional_b")
    public List<KsWj> optional_b(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountb();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_c")
    public List<KsWj> optional_c(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountc();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_d")
    public List<KsWj> optional_d(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountd();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_e")
    public List<KsWj> optional_e(){
        List<KsWj> ksWjs=ksWjMapper.selectbycounte();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_f")
    public List<KsWj> optional_f(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountf();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_g")
    public List<KsWj> optional_g(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountg();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_h")
    public List<KsWj> optional_h(){
        List<KsWj> ksWjs=ksWjMapper.selectbycounth();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_i")
    public List<KsWj> optional_i(){
        List<KsWj> ksWjs=ksWjMapper.selectbycounti();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_j")
    public List<KsWj> optional_j(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountj();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_k")
    public List<KsWj> optional_k(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountk();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_l")
    public List<KsWj> optional_l(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountl();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_m")
    public List<KsWj> optional_m(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountm();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_n")
    public List<KsWj> optional_n(){
        List<KsWj> ksWjs=ksWjMapper.selectbycountn();
        return ksWjs;
    }
    @ResponseBody
    @RequestMapping("/optional_o")
    public List<KsWj> optional_o(){
        List<KsWj> ksWjs=ksWjMapper.selectbycounto();
        return ksWjs;
    }

    @RequestMapping(value = "/wj",method = RequestMethod.GET)
    public String index(){
        return "wj";
    }
    @RequestMapping(value = "/fenxi",method = RequestMethod.GET)
    public String fenxi(){
        return "fenxi";
    }
}

